package cn.cocho.android.mc.comp.dialog;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import cn.cocho.android.mc.R;

public class LoadingDialog extends ProgressDialog {
	View view;
	TextView msgText = null;

	public LoadingDialog(Context context, String msg) {
		super(context);
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		view = inflater.inflate(R.layout.loading_dialog, null);
		msgText = (TextView) view.findViewById(R.id.loading_dialog_msg);
		msgText.setText(msg);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().getAttributes().gravity = Gravity.CENTER;
		setContentView(view);

	}

	public LoadingDialog(Context context, int theme) {
		super(context, theme);
	}

	@Override
	public void setTitle(CharSequence title) {
		super.setTitle(title);
	}

	@Override
	public void setMessage(CharSequence message) {
		super.setMessage(message);
		if (msgText != null) {
			msgText.setText(message);
		}
	}
}